***********************************************************************************
********"Macroprudential Regulation, Quantitative Easing, and Bank Lending"********
***********************************************************************************
* This file sets up 2 datasets, one with consolidated capital ratios and the other
* with monetary policy shocks from EA-MPD (Altavilla et al. 2019)
***********************************************************************************
***********************************************************************************


*==================================================================================
**# Bookmark (input)
clear *
import delimited using $inputdirectory/DS_bil_con.csv

rename data_oss_num time
tostring(time), replace
gen xxx=date(time, "YMD")
gen year=year(xxx)
gen month=month(xxx)
rename time oldtime
gen time=mofd(xxx)
drop xxx oldtime
format time %tm

gen ourt1r=100*s_t1/s_rwa
gen ourt1rtotal=100*s_t1/a_total

rename capogruppo bankid
keep bankid time year month ourt1r ourt1rtotal s_t1 s_rwa
keep if month==12
drop month
replace year=year+1

* Changes suggested by the supervisory department
* LINES NOT SHOWN

**# Bookmark (saving dataset - consolidated capital rations)
compress
save $inputdirectory/INB_capitalmonpol, replace


*==================================================================================
**# Bookmark (input)
clear *
import excel using $inputdirectory/MonPolShocks.xlsx, first

tostring(Date), replace
gen xxx=date(Date, "DMY")
gen time=mofd(xxx)
drop xxx Date
format time %tm

keep if time>=tm(2010m1)&time<=tm(2020m2)

keep OIS_* IT* time
tset time
replace OIS_SW=OIS_SW/100
replace IT10Y=IT10Y/100
replace IT2Y=IT2Y/100
gen lagIT10Y=L.IT10Y
gen lag2IT10Y=L2.IT10Y

**# Bookmark (saving dataset - monetary policy shokcs)
compress
save $inputdirectory/INB_shocksmonpol, replace
